package cn.doitedu.flink.ml

import org.apache.flink.api.scala._
import org.apache.flink.ml.common.LabeledVector
import org.apache.flink.ml.math.DenseVector

object BaseDemo {

  def main(args: Array[String]): Unit = {

    /**
     * 30,64,1,1
     * 30,62,3,1
     * 30,65,0,2
     * 31,59,2,1
     */

    val env = ExecutionEnvironment.getExecutionEnvironment
    val value: DataSet[(String, String, String, String)] = env.readCsvFile[(String, String, String, String)]("data/base.csv")

    val res: Seq[LabeledVector] = value.map(tp=>{
      val list = tp.productIterator.toList.map(_.asInstanceOf[String].toDouble)
      LabeledVector(list(3),DenseVector(list.take(3).toArray))
    })
      .collect()

    res.foreach(println)

    //env.execute()

  }

}
